﻿using System;
using System.Reflection;

namespace Kiwi.Container.DependencyInjection
{
    public class DependentProperty : IDependentProperty
    {
        public DependentProperty(object instance, PropertyInfo propertyInfo)
        {
            Instance = instance;
            PropertyInfo = propertyInfo;
        }

        public object Instance { get; set; }
        public PropertyInfo PropertyInfo { get; set; }

        #region IDependentProperty Members

        public Type Type
        {
            get { return PropertyInfo.PropertyType; }
        }

        public void Update(object component)
        {
            PropertyInfo.SetValue(Instance, component, null);
        }

        #endregion
    }
}